﻿using System;
using System.IO;
using HSS.Data;

namespace DuplicateFileExplorer
{
	public class FileSearchResultItem : IDataContainer
	{
		public FileSearchResultItem(FileInfo info)
		{
			if (null == info)
				throw new ArgumentNullException("info");

			this.Id = Guid.NewGuid().ToString();
			this.Info = info;
			this.Name = info.Name;
			this.FullName = info.FullName;
			this.Extension = info.Extension;
			this.CreationTime = info.CreationTime;
			this.LastWriteTime = info.LastWriteTime;
			this.LastAccessTime = info.LastAccessTime;
			var len = info.Length;
			this.Length = len;
			if (len > 1024)
				this.Size = (len / 1024).ToString() + " KB";
			else
				this.Size = len + " bytes";
			this.DirectoryName = info.DirectoryName;
		}

		public FileInfo Info { get; private set; }

		public string Id { get; set; }
		public string Name { get; set; }
		public string FullName { get; private set; }
		public string Extension { get; private set; }
		public DateTime CreationTime { get; private set; }
		public DateTime LastWriteTime { get; private set; }
		public DateTime LastAccessTime { get; private set; }
		public long Length { get; private set; }
		public string Size { get; private set; }
		public string DirectoryName { get; private set; }
		public object Data
		{
			get
			{
				return this;
			}
			set
			{
				throw new NotImplementedException();
			}
		}

	}
}
